package com.nondo.rdp.finance.repository.analysis;

import com.nondo.rdp.core.common.StatusConstant;
import com.nondo.rdp.finance.domain.analysis.Analysis;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Optional;

public interface AnalysisRepository extends JpaRepository<Analysis, Long>, JpaSpecificationExecutor<Analysis> {
    @Query("select a from Analysis a where a.id=:id and delFlag = '" + StatusConstant.DEL_FLAG_NORMAL + "'")
    Optional<Analysis> findOne(@Param("id") int id);

    @Modifying
    @Query("update Analysis set delFlag='" + StatusConstant.DEL_FLAG_DELETE + "' where id = ?1")
    void deleteById(Long id);

    Analysis save(Analysis analysis);
    
    Analysis findByWsId(Long wsId);
}
